﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dpptask2.Exceptions;

namespace dpptask2.OptionClasses
{
    public class optionBoolAttribute : optionParametrizedAttribute
    {
        public override Type typeAccepted()
        {
            if (choiceRequired)
                return typeof(bool);
            else
                return typeof(bool?);
        }


        public override object createValueFromString(string stringValue)
        {
            switch (stringValue.ToLower())
            {
                case "true": return true;
                case "false": return false;
                default: throw new ParserException("{0} is not correct bool value, use true or false.", stringValue);
            }
        }
    }
}
